<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

	<input type="button" value="ajax 方式" onclick="ajax()"/><br/> <!-- html按钮 点击事件 -->
	<script src="js/jquery.min.js"></script>
	<script type="text/javascript">
		/* 
		function ajax() {
			$.ajax({
				url : "${pageContext.request.contextPath}/ajax", // url：请求服务器端地址
				async : true, // 可以不写，默认就是true，代表异步
				data : {"name" : "王五", "age" : 40}, // 发送到服务器的参数，建议使用json格式
				success : function(data) {           //成功响应执行的函数，对应的类型是function类型
					// {"name":"李四","age":23}
					console.log("name: " + data.name + ", age: " + data.age);
				},
				dataType : "json",
				type : "POST"
			});
		}
		*/
	function ajax() {
		$.ajax({
			url:"${pageContext.request.contextPath}/ajax",
			async:true,
			data:{"name" : "王五", "age" : 40},
			success:function(data){
			console.log("name:" + data.name + ", age:" + data.age);
			},
			dataType:"json",
			type:"post"
		});
	}
	</script>
</body>
</html>